<template>
  <div class="side-bar">
    <scroll :probe-type="3" class="cg-scroll" ref="scroll">
      <button
        class="side-bar-item"
        v-for="(item, index) in categoryList"
        :key="index"
        :class="{ active: currentIndex === index }"
        @click="sideItemClick(index)"
      >
        <div>{{ item.title }}</div>
      </button>
    </scroll>
  </div>
</template>

<script>
import Scroll from "components/common/scroll/Scroll.vue";
export default {
  components: { Scroll },
  data() {
    return {
      currentIndex: 0,
    };
  },
  props: {
    categoryList: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  methods: {
    sideItemClick(index) {
      this.currentIndex = index;

      this.$emit("sideItemClick", index);
    },
  },
};
</script>

<style scoped>
.side-bar {
  text-align: center;
  width: 100px;
}
.side-bar-item {
  display: block;
  height: 44px;
  width: 100%;
  background-color: #f6f6f6;
  text-align: center;

  border: 0;
}
.cg-scroll {
  position: absolute;
  width: 100px;

  right: 0;
  left: 0;
  top: 44px;
  bottom: 50px;
}
.active {
  font-weight: 700;
  color: #ff5777;
  border-left: 3px solid #ff5777;
  background-color: #ffffff;
}
</style>